#ifndef COMMAND_EDM_H_INCLUDED
#define COMMAND_EDM_H_INCLUDED
/*
      protocol format (dispatcher as server):
 *      ----------------------------------------------------------------------        

        tcp header struct definition:

 *          magic:   edm_uint8_t;  //! 幻数
            command: edm_uint8_t;  //! 命令编号
            len:     edm_uint32_t; //! json len
            reserve: edm_uint64_t; //! 主要用于任务编号的存储

        ========= gloable ======================================

        1. [s -> c] request status 
           command: 1
           len: 0
           reserve: 0 

        2. [c -> s] reponse status 
           command: 2
           len: body len
           reserve: 0 
           prepare body: {"prepare_id": "bind.ip.address.", "block":["qq.com", "vip.qq.com", "foxmail.com"]}
              
 * 
        3. [c -> s] block msp notification  
           command: 3
           len: body len
           reserve: 0 
           body: {"block":["qq.com"]}

        4. [c -> s] unblock msp notification  
           command: 4
           len: body len
           reserve: 0 
           body: {"unblock":["qq.com"]}
 * 
        5. [c -> s] prepare spy queue status
           command: 5
           len: body len
           reserve: 0 
           body: {"host":"ip", "work":10, "wait":60, "retry":0, "block":9, "stopped":10}
        ========= task ======================================

        11. [s -> c] task delivery request
           command: 11
           len: body len
           reserve: taskid 
		   body: {"from":{"name":"", "addr":""}, "to":"", "replace":["",""], "top":"", "bottom":""}

        12. [c -> s] msp delivery statistics
           command: 12
           len: body len
           reserve: taskid 
		   body: {"delivery":[{"addr":"aa@sina.com", "code":0}, {"addr":"bb@sina.com", "code":0}]}

        13. [c -> s] task template missed at memcached notification
           command: 13
           len: body len
           reserve: taskid 

        14. [s -> c] task delivery pause
           command: 14
           len: body len
           reserve: taskid 

        15. [s -> c] task delivery start
           command: 15
           len: body len
           reserve: taskid 

        16. [s -> c] task delivery delete
           command: 16
           len: body len
           reserve: taskid 
        
 *     ========= monitor(client) ====================================== 
 *      90. [c->s] helo 
 *          command: 90
            len: body len
            reserve: 0
 *          body: {"monitor-id":"host_ip"}      
 *      91. [c->s] noop  
 *          command: 91
            len: body len
            reserve: 0
 *      92. [s->c] noop
 *          command: 92
            len: body len
            reserve: 0
 *      93. [s->c] restart sick prepare         
 *          command: 93
            len: body len
            reserve: 0
 *          body: {"prepare":["ip1","ip2","ip3"]}
 *      ----------------------------------------------------------------------        
 *      
 *      protocol format (memcache): memcache protocol
 */

namespace edm
{
    namespace common
    {
        //! dispatch <-> prepare commander
        enum COMMANDER{
            CMD_NONE = 0,
            CMD_S2C_STATUS = 1,
            CMD_C2S_STATUS,
            CMD_C2S_BLOCK,
            CMD_C2S_UNBLOCK,
            CMD_C2S_SPY,
            CMD_S2C_TASK_DELIVERY = 11,
            CMD_C2S_MSP_RESPONSE,
            CMD_C2S_TEMPLATE_MISSED,
            CMD_S2C_TASK_PAUSE,
            CMD_S2C_TASK_START,
            CMD_S2C_TASK_DELETE,
            S2C_CMD_COUNT,
	    CMD_W2S_TASK_PAUSE,
	    CMD_W2S_TASK_DELETE,
	    W2S_CMD_COUNT,
            MON_C2S_HELO = 90,
            MON_C2S_NOOP,
            MON_S2C_NOOP,
            MON_S2C_RESTART,
            MON_CMD_COUNT
        };
        
        //! smtp low code
        enum SMTP_LOW_CODE
        {
            MX_S_OK = 0,       //0 mail sent
            MX_S_TO_DOMAIN = 1,    //1 invalid receipt mail address
            MX_S_TO_PAUSED,    //2 domain of receipt is currently paused
            MX_S_TO_MX,        //3 cannot find MX for receipt's domain
            MX_S_TO_DOWN,      //4 MX of receipt is down
            MX_S_TO_FROZEN,    //5 MX of receipt is frozen (TCP timeout)
            MX_S_TO_USER,      //6 mail address is unknown to MX
            MX_S_FROM_DOMAIN,  //7 invalid sender mail address
            MX_S_SMTP_HELO,    //8 non-250 returned after HELO sent
            MX_S_SMTP_MAIL,    //9 non-250 returned after MAIL FROM sent
            MX_S_SMTP_RCPT,    //10 non-250 returned after RCPT TO sent
            MX_S_SMTP_DATA,    //11 non-354 returned after DATA sent
            MX_S_SMTP_DOT,     //12 non-250 returned after '.' sent
            MX_S_SMTP_LOST,    //13 smtp delivery lost status
            
            FILTER_INVALID = 21, //! 21 invalid reciver addr
            FILTER_FREQUENT_EXCEED, //! 22 reciever frequent exceed
            
            OPERATOR_DELETED = 31, //! operator deleted
            SYSTEM_TEMPERR_RETRY_EXCEED,  //! 超过重试次数仍然失败
        };
    
        //! smtp high code 
        enum SMTP_HIGH_CODE
        {
            SMTP_OK = 0,
            SMTP_RETRY = 100,
            SMTP_FAILED = 200
        };
        
    }
}
        



#endif
